Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick ot_certs changes #20915

Merged
merged 9 commits into from
Jan 23, 2024

Conversation

pamaury
Copy link
Contributor

@pamaury pamaury commented Jan 22, 2024

No description provided.

This data can be used to exercise every piece of code that works
with data, such as asn1 der generator and the asn1 codegen. More
generally it can be used to create random certificates for testing.
At the moment it generates random data but this could be extended
to generate edges cases as well.

Signed-off-by: Amaury Pouly <[email protected]>
Due to the hashmap using a nondeterministic order, it could differ
between runs. Sort the entries to make sure this does not happen.

Signed-off-by: Amaury Pouly <[email protected]>
The generator now output C++ unittest, those are compiled and
turned into a bazel test by the bazek certificate macro.

Signed-off-by: Amaury Pouly <[email protected]>
The code currently always allocates 3 bytes for the length and then
moves the data forward if we need less bytes than requires. This works
but means that the code could throw a kErrorAsn1BufferExhausted when
producing a document even though the final encoding would actually fit
into the buffer.

This commit changes the behaviour so that the code now allocates only
1 byte for the length initially and moves the data backwards on finish
if necessary. This guarantees that if the final document fits in the
buffer, then the code will successfully produces it. This requires a bit
of shuffling around in the code. It also requires a bit more care to
avoid an accidental buffer overflow when moving the data. There is a
unittest to specifically test corner cases in the moving code to make
sure we never write past the end of the buffer.

Signed-off-by: Amaury Pouly <[email protected]>
The code was double counting in some code path. Also the code was
under-estimating the size of unsigned integers due to a quirk of
ASN1 integer encoding that might require a padding with a 0x00
byte.

Signed-off-by: Amaury Pouly <[email protected]>
@pamaury pamaury requested review from cfrantz and a team as code owners January 22, 2024 11:39
@pamaury pamaury requested review from timothytrippel and removed request for a team January 22, 2024 11:39
@pamaury pamaury merged commit dec6c29 into lowRISC:earlgrey_es_sival Jan 23, 2024
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants